/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package com.lineage.server.command.executor;

import java.util.StringTokenizer;

import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.map.L1VirtualMap;
import com.lineage.server.packetserver.S_SystemMessage;

/**
 * Class <code>L1AddVirtualMap</code> GM指令:增加虚拟地图.
 * 
 * @author jrwz
 * @version 2012-7-13上午08:55:42
 * @see com.lineage.server.command.executor
 * @since JDK1.7
 */
public final class L1AddVirtualMap implements L1CommandExecutor {

    /**
     * 取得实例.
     * 
     * @return 实例
     */
    public static L1CommandExecutor getInstance() {
        return new L1AddVirtualMap();
    }

    /** GM指令:增加虚拟地图. */
    private L1AddVirtualMap() {
    }

    @Override
    public void execute(final L1PcInstance pc, final String cmdName,
            final String arg) {
        try {
            final StringTokenizer st = new StringTokenizer(arg);
            final int mapid = Integer.parseInt(st.nextToken());
            final int buf = L1VirtualMap.getInstance().addVirtualMap(mapid);
            pc.sendPackets(new S_SystemMessage("虚拟地图[" + buf + "]已经生成(" + mapid
                    + ")"));
        } catch (final Exception e) {
            pc.sendPackets(new S_SystemMessage(cmdName + " 请输入地图ID。"));
        }
    }
}
